
// import { JSONSchemaType, DefinedError} from "../../node_modules/ajv/dist/ajv"
// import Ajv from "../../node_modules/ajv/dist/ajv"
// const ajv = new Ajv()

// type MyData = {foo: number}

// // Optional schema type annotation for schema to match MyData type.
// // To use JSONSchemaType set `strictNullChecks: true` in tsconfig `compilerOptions`.
// const schema: JSONSchemaType<MyData> = {
//   type: "object",
//   properties: {
//     foo: {type: "number", minimum: 0,nullable: true},
//   },
//   required: [],
//   additionalProperties: false,
// }

// // validate is a type guard for MyData - type is inferred from schema type
// const validate = ajv.compile(schema)

// // or, if you did not use type annotation for the schema,
// // type parameter can be used to make it type guard:
// // const validate = ajv.compile<MyData>(schema)

// const data: any = {foo: 1}

// if (validate(data)) {
//   // data is MyData here
//   console.log(data.foo)
// } else {
//   // The type cast is needed to allow user-defined keywords and errors
//   // You can extend this type to include your error types as needed.
//   for (const err of validate.errors as DefinedError[]) {
//     switch (err.keyword) {
//       case "minimum":
//         // err type is narrowed here to have "minimum" error params properties
//         console.log(err.params.limit)
//         break
//       // ...
//     }
//   }
// }